﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using AwesomeEnginePC.Inputs;
using AwesomeEnginePC.Graphics.TwoDimensional.Text;
using AwesomeEnginePC.Graphics.TwoDimensional.Sprites;
using AwesomeEnginePC.Audio;
using AwesomeEnginePC.Networking.Sockets;
using System.Net;
using AwesomeEnginePC.Physics;

namespace DevTesting
{
    public class KevinsTestingGround : BaseTestingGround
    {
        public enum InputNames
        {
            //mouse
            ClickMouse,
            RightClick,
        }

        InputTypeMouse<InputNames> mouseInput;

        BaseSprite cursor;

        BaseSpriteButton btnSpriteWithBack;
        BaseSpriteButton btnSpriteNoBack;
        BaseString strButtonStatusOutput;

        public override void Init()
        {
            mouseInput = new InputTypeMouse<InputNames>();
            mouseInput.AddBinding(InputNames.ClickMouse, MouseButton.LeftButton);
            mouseInput.AddBinding(InputNames.RightClick, MouseButton.RightButton);
        }

        public override void LoadContent(ContentManager cm)
        {
            cursor = new BaseSprite(cm, "pictures/cursorSmall");

            btnSpriteWithBack = new BaseSpriteButton(cm, "fonts/SpriteFont1", "pictures/buttonBackground");
            btnSpriteWithBack.Text = "First";
            btnSpriteWithBack.Position = new Vector<int>(20, 20);

            btnSpriteNoBack = new BaseSpriteButton(cm, "fonts/SpriteFont1", null);
            btnSpriteNoBack.Position.X = 30;
            btnSpriteNoBack.Position.Y = 250;
            btnSpriteNoBack.Text = "Second";

            strButtonStatusOutput = new BaseString(cm, "fonts/SpriteFont1", "hey");
            strButtonStatusOutput.Position.Y = 500;
        }

        public override void Update(GameTime gameTime)
        {
            mouseInput.Update();

            cursor.Position = mouseInput.MousePosition;

            //strButtonStatusOutput.Text = "nothing";

            if (btnSpriteNoBack.IsPointOnObject(mouseInput.MousePosition))
            {
                strButtonStatusOutput.Text = "On button";
            }
            else
            {
                strButtonStatusOutput.Text = "false";
            }
            
        }

        public override void Draw(GameTime gameTime, SpriteBatch sb)
        {
            btnSpriteWithBack.Draw(gameTime, sb);
            btnSpriteNoBack.Draw(gameTime, sb);
            cursor.Draw(gameTime, sb);
            strButtonStatusOutput.Draw(gameTime, sb);
        }

    }

    public abstract class BaseTestingGround
    {
        public abstract void Init();
        public abstract void LoadContent(ContentManager cm);
        public abstract void Update(GameTime gameTime);
        public abstract void Draw(GameTime gameTime, SpriteBatch sb);
    }
}
